package v9.assist.analyst

import android.graphics.Bitmap
import kotlinx.coroutines.script.Block
import kotlinx.coroutines.script.TARGET
import kotlinx.coroutines.script.analysis.Analysis
import kotlinx.coroutines.script.SMapBase.hitDeathRed
import kotlinx.coroutines.script.SMapBase.hitEquipO
import kotlinx.coroutines.script.SMapBase.hitSMapEnemyBlue
import kotlinx.coroutines.script.SMapBase.hitSMapEnemyYellow
import kotlinx.coroutines.script.SMapBase.hitTeammate
import kotlinx.coroutines.script.tes.ColorDiffer
import kotlinx.coroutines.script.tes.printLog
import kotlinx.coroutines.script.tes.pt
import kotlinx.coroutines.script.tes.rgb
import kotlinx.coroutines.script.tes.shake
import v9.assist.script.xBossBesideTs
import v9.assist.script.xLastAtkTs
import v9.assist.script.xLastPetBlacksmithTs
import v9.assist.script.xLastSceneEnterTs
import v9.assist.script.xLastUnknownTs
import kotlin.math.abs

private val hitRoad by lazy { // 21-28
    val out = mutableSetOf<ColorDiffer>()
     out.addAll(setOf(0xff201E19.toInt().rgb(6),)) // 最后boss深黑
    out.addAll(setOf(0xff39342B.toInt().rgb(6),))
    out.addAll(setOf(0xff42443F.toInt().rgb(20),)) // 仪式2
    out.addAll(hitEquipO)
    out.addAll(hitDeathRed)
    out.addAll(hitTeammate)
    out.addAll(hitSMapEnemyYellow)
    out.addAll(hitSMapEnemyBlue)
    out
}
// p1 往上  p2 往右下. p3.往  p4去1层boss 左 . p5去1层boss右上
// p6 第二层起点
var anaPathfindingModeFM = MODE_PATHFINDING_P1
private var counterSwitchToP3 = 0
private var lastCounterSwitchToP3Ts = 0L
var anaLastSMapFMFeature1Ts = 0L //
var anaLastSMapFMFeature2Ts = 0L //
var anaLastSMapFMFeature3Ts = 0L //
var anaLastSMapFMFeature4Ts = 0L // 直通
var anaLastSMapFMFeature5Ts = 0L // P2起点往下
var anaLastSMapFMFeature6Ts = 0L // P2往上走到P3
var anaLastSMapFMFeature7Ts = 0L // P5 1层Boss击破去新场景
var anaLastSMapFMFeature8Ts = 0L //
var anaLastSMapFMFeature9Ts = 0L //
var anaLastSMapFMFeature10Ts = 0L // P4 回去的第一个左侧卡角
var anaLastSMapFMFeature11Ts = 0L //
var anaLastSMapFMFeature12Ts = 0L // P5 开门靠上
var anaLastSMapFMFeature13Ts = 0L // P5 开门靠下
var anaLastSMapFMFeature14Ts = 0L // P5 开门正门
var anaLastSMapFMFeature15Ts = 0L // P4 去P5错路下面
var anaLastSMapFMFeature16Ts = 0L // P4 去P5错路左侧死胡同
var anaLastSMapFMFeature17Ts = 0L
var anaLastSMapFMFeature18Ts = 0L // P6 电梯传送口
var anaLastSMapFMFeature19Ts = 0L //
var anaLastSMapFMFeature20Ts = 0L // p6起点
var anaLastSMapFMFeature21Ts = 0L //

fun rasterizeMapFM(ss: Bitmap): Array<IntArray> {
    return rasterizeMap(ss, hitRoad)
}

fun analysisMapFM(ss: Bitmap) {
    analysisMapElements(ss)
    val returnMapArray = rasterizeMapFM(ss)

    val te = mapEnemyList.randomOrNull()
    val lastSMapTargetToEnemyDs = if (te == null) Int.MAX_VALUE else mapElementDistance(te)

    if (blockEliteEnemyBoss != null && mapEnemyList.isNotEmpty()) {
        // 优先Boss
        mapTargetList.add(mapEnemyList.random())
        printLog { "analyst target to boss" }
        lastSMapTargetToBossTs = System.currentTimeMillis()
        if (mapElementDistance(blockEliteEnemyBoss) < 30.pt) xBossBesideTs = System.currentTimeMillis()

        if (anaPathfindingModeFM == MODE_PATHFINDING_P3 || anaPathfindingModeFM == MODE_PATHFINDING_P4) {
            printLog { "analystFM. 副本第1层状态遇见Boss修正到P5" }
            anaPathfindingModeFM = MODE_PATHFINDING_P5
        }
    } else if (mapNpcList.size > 0 && System.currentTimeMillis() - lastSMapTargetToBossTs > 6000) {
        mapTargetList.add(mapNpcList.random())
        printLog { "analyst target to npc" }
        lastSMapTargetToNpcTs = System.currentTimeMillis()
    } else if (lastSMapTargetToEnemyDs < 60
        && System.currentTimeMillis() - anaLastPageSceneEnterTs > 10000 // 刚开局就需要
        && System.currentTimeMillis() - anaLastSceneSettleTs > 20000
        && !bsSceneSettle && !bsSceneSettleBlacksmith) {
        // 优先敌人
        mapTargetList.add(mapEnemyList.random())
        printLog { "analyst target to elite enemy" }
    } else if (bsSceneSettleBlacksmith && mapBlacksmithList.isNotEmpty()) {
        mapTargetList.add(mapBlacksmithList.random())
        printLog { "analyst target to blacksmith" }
    } else if (bsSceneSettle && mapBlueDoorList.isNotEmpty()) {
        mapTargetList.add(mapBlueDoorList.random())
        printLog { "analyst target to blueDoor" }
    } else if (mapSampleArrived.size > 0) {
        if (anaPathfindingModeFM == MODE_PATHFINDING_P1) {
            mapTopNotArrived.minByOrNull { it.first }?.also {
                mapTargetList.add(it)
                printLog { "analyst target P1 P1 P1 to top left" } //
            }
            if (mapTargetList.isEmpty()) {
                mapSampleArrived.minByOrNull { it.second }?.also {
                    mapTargetList.add(it)
                    printLog { "analyst target P1 P1 P1 to sample top" } //
                }
            }
        } else if (anaPathfindingModeFM == MODE_PATHFINDING_P2 ) {
            mapBottomNotArrived.maxByOrNull { it.first }?.also {
                mapTargetList.add(it)
                printLog { "analyst target P2 P2 P2 to bottom right" } //
            }
        } else if (anaPathfindingModeFM == MODE_PATHFINDING_P3) {
            mapRightNotArrived.minByOrNull { it.second }?.also {
                mapTargetList.add(it)
                printLog { "analyst target P3 P3 P3 to right top" } //
            }
            if (mapTargetList.isEmpty()) {
                mapTopNotArrived.maxByOrNull { it.first }?.also {
                    mapTargetList.add(it)
                    printLog { "analyst target P3 P3 P3 to top right" } //
                }
            }
            if (mapTargetList.isEmpty()) {
                mapSampleArrived.maxByOrNull { it.first }?.also {
                    mapTargetList.add(it)
                    printLog { "analyst target P3 P3 P3 to sample right" } //
                }
            }
        } else if ( anaPathfindingModeFM == MODE_PATHFINDING_P4 ) {
            mapLeftNotArrived.minByOrNull { it.second }?.also {
                mapTargetList.add(it)
                printLog { "analyst target P4 P4 P4 to left top" } //
            }
            // 这里有风险往上走过头
            if (mapTargetList.isEmpty()) {
                mapBottomNotArrived.minByOrNull { it.first }?.also {
                    mapTargetList.add(it)
                    printLog { "analyst target P4 P4 P4 to bottom left" } //
                }
            }
        } else if ( anaPathfindingModeFM == MODE_PATHFINDING_P5 ) {
            mapTopNotArrived.maxByOrNull { it.first }?.also {
                mapTargetList.add(it)
                printLog { "analyst target P5 P5 P5 to top right" } //
            }
            if (mapTargetList.isEmpty()) {
                mapSampleArrived.minByOrNull { it.second }?.also {
                    mapTargetList.add(it)
                    printLog { "analyst target P5 P5 P5 to sample top" } //
                }
            }
        } else if ( anaPathfindingModeFM == MODE_PATHFINDING_P6 ) {
            mapSampleArrived.maxByOrNull { it.first }?.also {
                mapTargetList.add(it)
                printLog { "analyst target P6 P6 P6 to sample right" } //
            }
        }
    }

    if (mapTargetList.isNotEmpty()) {
        val target = mapTargetList.random()
        returnMapArray[target.first][target.second] = TARGET
    }

    angleByRoad = analysisRasterizeMap(returnMapArray)
    angleByRoad = angleSpecialAdjust(angleByRoad ?: 90.shake(10))

    // map feature
    analysisMapFMIsStartPoint(ss)
    if ((blockBlueDoor == null || blockBlacksmith == null)
        && System.currentTimeMillis() - lastEliteEnemyBossTs > 10000) {
        printLog { "analystFM $mapSimpleStatus" }

        if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && lastMapTopP == null
            && (lastMapBottomP == null || (lastMapBottomP ?: -1f) in 0.70 .. 0.80)
            && lastMapLeftP == null
            && (lastMapRightP ?: -1f) in 0.63 .. 0.80
            && System.currentTimeMillis() - xLastUnknownTs > 500
            && System.currentTimeMillis() - anaLastSMapFMFeature20Ts > 12000
        ) {
            printLog { "analystFM 节点.副本外入口 A" }
            // [上,49s,c:0][下,0s,0.7584746,c:10][左,25s,c:0][右,0s,0.71870285,c:17]][Road,c:11]
            // [上,1746843741s,c:0][下,0s,0.7330508,c:1][左,1746843741s,c:0][右,0s,0.6689977,c:11]][Road,c:4]
            // [上,1746843863s,c:0][下,0s,0.7727754,c:8][左,1746843863s,c:0][右,0s,0.7724359,c:8]][Road,c:3]
            anaLastSMapFMFeature1Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && lastMapTopP == null
            && lastMapBottomP == null
            && lastMapLeftP == null
            && lastMapRightP == null
            && anaPathfindingModeFM != MODE_PATHFINDING_P6
            && !bsSceneSettle && !bsSceneSettleBlacksmith
            && System.currentTimeMillis() - lastBlueDoorTs > 2000
            && System.currentTimeMillis() - anaLastSceneSettleTs > 8000
        ) {
            printLog { "analystFM 节点.副本外入口 B" }
            // [上,16s,c:0][下,0s,c:0][左,34s,c:0][右,0s,c:0]][Road,c:1]
            anaLastSMapFMFeature1Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.77 .. 0.86
            && (lastMapBottomP ?: -1f) in 0.30 .. 0.45
            && lastMapLeftP == null
            && (lastMapRightP ?: -1f) in 0.23 .. 0.31
        ) {
            printLog { "analystFM 节点.直通" }
            // [上,0s,0.8143963,c:27][下,0s,0.36962193,c:13][左,510s,c:0][右,0s,0.27053142,c:23]][Road,c:39]
            // [上,0s,0.80707264,c:27][下,0s,0.3348544,c:13][左,523s,c:0][右,0s,0.2542735,c:26]][Road,c:39]
            // [上,0s,0.8345996,c:29][下,0s,0.4202393,c:17][左,532s,c:0][右,0s,0.2863248,c:24]][Road,c:38]
            anaLastSMapFMFeature4Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.40 .. 0.53
            && (lastMapLeftP == null || (lastMapLeftP ?: -1f) in 0.81 .. 0.87)
            && lastMapRightP == null
            && System.currentTimeMillis() - xLastUnknownTs > 6000
            && System.currentTimeMillis() - xLastSceneEnterTs > 8000
            && anaPathfindingModeFM == MODE_PATHFINDING_P1
        ) {
            printLog { "analystFM 节点.P1顶端回头清理1阶段怪物" }
            // [上,42s,c:0][下,0s,0.47950983,c:71][左,12s,c:0][右,40s,c:0]][Road,c:36]
            // [上,9s,c:0][下,0s,0.36653563,c:69][左,0s,0.8490029,c:6][右,3s,c:0]][Road,c:45]
            anaLastSMapFMFeature2Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapBottomNotArrivedTs > 5000
            && System.currentTimeMillis() - xLastAtkTs > 5000
            && anaPathfindingModeFM == MODE_PATHFINDING_P2
        ) {
            printLog { "analystFM 节点.P2到底了.切换去右侧房间清理节点怪 A $counterSwitchToP3" }
            if (System.currentTimeMillis() - lastCounterSwitchToP3Ts < 2000) {
                counterSwitchToP3++
                if (counterSwitchToP3 > 2) {
                    printLog { "analystFM 节点.P2到底了.切换去右侧房间清理节点怪 A 执行" }
                    anaPathfindingModeFM = MODE_PATHFINDING_P3
                }
            } else counterSwitchToP3 = 0
            lastCounterSwitchToP3Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 3000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.35 .. 0.43
            && lastMapBottomP == null
            && (lastMapLeftP ?: -1f) in 0.38 .. 0.46
            && (lastMapRightP ?: -1f) in 0.13 .. 0.26
        ) {
            // [上,0s,0.38002467,c:87][下,29s,c:0][左,0s,0.4199515,c:67][右,0s,0.16880342,c:20]][Road,c:70]
            // [上,0s,0.40405223,c:87][下,47s,c:0][左,0s,0.42521366,c:68][右,0s,0.23290598,c:18]][Road,c:79]
            printLog { "analystFM 节点.P2到底了.切换去右侧房间清理节点怪 B $counterSwitchToP3" }
            if (System.currentTimeMillis() - lastCounterSwitchToP3Ts < 2000) {
                counterSwitchToP3++
                if (counterSwitchToP3 > 2) {
                    printLog { "analystFM 节点.P2到底了.切换去右侧房间清理节点怪 B 执行" }
                    anaPathfindingModeFM = MODE_PATHFINDING_P3
                    anaLastSMapFMFeature6Ts = System.currentTimeMillis()
                }
            } else counterSwitchToP3 = 0
            lastCounterSwitchToP3Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 3000
            && (lastMapTopP ?: -1f) in 0.20 .. 0.41
            && (lastMapBottomP == null || (lastMapBottomP ?: -1f) in 0.06 .. 0.15)
            && (lastMapLeftP ?: -1f) in 0.24 .. 0.40
            && lastMapRightP == null
        ) {
            // [上,0s,0.28335506,c:65][下,0s,0.101493135,c:14][左,0s,0.36752138,c:35][右,62s,c:0]][Road,c:51]
            // [上,0s,0.356831,c:66][下,0s,0.097457625,c:2][左,0s,0.33423984,c:33][右,106s,c:0]][Road,c:51]
            // [上,0s,0.39164647,c:70][下,3s,c:0][左,0s,0.34986505,c:38][右,74s,c:0]][Road,c:53]
            // [上,0s,0.36622274,c:70][下,12s,c:0][左,0s,0.33119658,c:50][右,82s,c:0]][Road,c:51]
            // [上,0s,0.38211647,c:78][下,23s,c:0][左,0s,0.25975975,c:37][右,94s,c:0]][Road,c:56]
            //  [上,0s,0.2328354,c:59][下,0s,0.10922787,c:24][左,0s,0.35722613,c:44][右,2s,c:0]][Road,c:52]
            printLog { "analystFM 节点.P2到底了.切换去右侧房间清理节点怪 C $counterSwitchToP3" }
            if (System.currentTimeMillis() - lastCounterSwitchToP3Ts < 2000) {
                counterSwitchToP3++
                if (counterSwitchToP3 > 2) {
                    printLog { "analystFM 节点.P2到底了.切换去右侧房间清理节点怪 C 执行" }
                    anaPathfindingModeFM = MODE_PATHFINDING_P3
                    anaLastSMapFMFeature6Ts = System.currentTimeMillis()
                }
            } else counterSwitchToP3 = 0
            lastCounterSwitchToP3Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 3000
            && (lastMapTopP ?: -1f) in 0.21 .. 0.29
            && (lastMapBottomP ?: -1f) in 0.18 .. 0.32
            && (lastMapLeftP ?: -1f) in 0.46 .. 0.58
            && lastMapRightP == null
        ) {
            // [上,0s,0.26716316,c:66][下,0s,0.2102611,c:37][左,0s,0.5514922,c:61][右,36s,c:0]][Road,c:71]
            // [上,0s,0.24176084,c:60][下,0s,0.29682747,c:26][左,0s,0.49117428,c:46][右,13s,c:0]][Road,c:70]
            printLog { "analystFM 节点.P2到底了.切换去右侧房间清理节点怪 D $counterSwitchToP3" }
            if (System.currentTimeMillis() - lastCounterSwitchToP3Ts < 2000) {
                counterSwitchToP3++
                if (counterSwitchToP3 > 2) {
                    printLog { "analystFM 节点.P2到底了.切换去右侧房间清理节点怪 D 执行" }
                    anaPathfindingModeFM = MODE_PATHFINDING_P3
                    anaLastSMapFMFeature6Ts = System.currentTimeMillis()
                }
            } else counterSwitchToP3 = 0
            lastCounterSwitchToP3Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.28 .. 0.57
            && lastMapLeftP == null
            && lastMapRightP == null
            && System.currentTimeMillis() - xLastUnknownTs > 6000
            && System.currentTimeMillis() - xLastSceneEnterTs > 8000
            && anaPathfindingModeFM == MODE_PATHFINDING_P3
        ) {
            printLog { "analystFM 节点.P3顶端回头清理2阶段怪物 A" }
            // [上,64s,c:0][下,0s,0.54259706,c:63][左,64s,c:0][右,65s,c:0]][Road,c:49]
            // [上,2s,c:0][下,0s,0.30786806,c:68][左,2s,c:0][右,129s,c:0]][Road,c:72]
            // [上,2s,c:0][下,0s,0.3953413,c:61][左,15s,c:0][右,142s,c:0]][Road,c:66]
            anaLastSMapFMFeature3Ts = System.currentTimeMillis() // script有战斗超时变成p4
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.30 .. 0.44
            && (lastMapBottomP ?: -1f) in 0.22 .. 0.36
            && (lastMapLeftP ?: -1f) in 0.60 .. 0.96
            && lastMapRightP == null
            && System.currentTimeMillis() - xLastUnknownTs > 6000
            && System.currentTimeMillis() - xLastSceneEnterTs > 8000
            && anaPathfindingModeFM == MODE_PATHFINDING_P3
        ) {
            printLog { "analystFM 节点.P3顶端回头清理2阶段怪物 B" }
            // [上,0s,0.32521185,c:4][下,0s,0.2511825,c:43][左,0s,0.61217946,c:16][右,17s,c:0]][Road,c:29]
            // [上,0s,0.41525424,c:1][下,0s,0.2849341,c:75][左,0s,0.9202279,c:3][右,100s,c:0]][Road,c:71]
            // [上,0s,0.36581922,c:6][下,0s,0.2540306,c:41][左,0s,0.63986015,c:11][右,88s,c:0]][Road,c:30]
            // [上,0s,0.3940678,c:1][下,0s,0.3375706,c:45][左,0s,0.5641026,c:1][右,1746845809s,c:0]][Road,c:28]
            anaLastSMapFMFeature3Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
            && System.currentTimeMillis() - xLastAtkTs > 4000
            && System.currentTimeMillis() - lastBlueDoorTs < 2000
            && anaPathfindingModeFM == MODE_PATHFINDING_P4
        ) {
            printLog { "analystFM 节点.P4特征位去右上角Boss A" }
            anaPathfindingModeFM = MODE_PATHFINDING_P5
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.11 .. 0.18
            && (lastMapBottomP ?: -1f) in 0.56 .. 0.64
            && (lastMapLeftP ?: -1f) in 0.10 .. 0.17
            && (lastMapRightP ?: -1f) in 0.68 .. 0.74
            && anaPathfindingModeFM == MODE_PATHFINDING_P4
        ) {
            // [上,0s,0.15572034,c:40][下,0s,0.61227614,c:59][左,0s,0.14245014,c:15][右,0s,0.716999,c:45]][Road,c:74]
            // [上,0s,0.14422049,c:37][下,0s,0.60982853,c:58][左,0s,0.1382784,c:14][右,0s,0.74543774,c:37]][Road,c:77]
            printLog { "analystFM 节点.P4特征位去右上角Boss B1" }
            anaPathfindingModeFM = MODE_PATHFINDING_P5
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.24 .. 0.32
            && (lastMapBottomP ?: -1f) in 0.66 .. 0.90
            && (lastMapLeftP ?: -1f) in 0.26 .. 0.52
            && (lastMapRightP ?: -1f) in 0.83 .. 0.90
            && anaPathfindingModeFM == MODE_PATHFINDING_P4
        ) {
            // [上,0s,0.28993323,c:55][下,0s,0.7337814,c:29][左,0s,0.5052687,c:73][右,0s,0.8751187,c:18]][Road,c:70]
            // [上,0s,0.27087256,c:54][下,0s,0.6889965,c:42][左,0s,0.2889957,c:40][右,0s,0.88595086,c:16]][Road,c:63]
            // [上,0s,0.29070362,c:55][下,0s,0.88135594,c:15][左,0s,0.46283907,c:46][右,0s,0.86999553,c:19]][Road,c:81]
            printLog { "analystFM 节点.P4特征位去右上角Boss B2" }
            anaPathfindingModeFM = MODE_PATHFINDING_P5
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.48 .. 0.59
            && (lastMapBottomP ?: -1f) in 0.38 .. 0.48
            && (lastMapLeftP ?: -1f) in 0.72 .. 0.83
            && (lastMapRightP ?: -1f) in 0.71 .. 0.81
            && anaPathfindingModeFM == MODE_PATHFINDING_P4
        ) {
            // [上,0s,0.51540834,c:66][下,0s,0.4670433,c:69][左,0s,0.74786323,c:35][右,0s,0.7441078,c:33]][Road,c:77]
            // [上,0s,0.5602517,c:79][下,0s,0.40837795,c:76][左,0s,0.8185703,c:22][右,0s,0.78909004,c:34]][Road,c:83]
            printLog { "analystFM 节点.P4特征位去右上角Boss B3" }
            anaPathfindingModeFM = MODE_PATHFINDING_P5
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.48 .. 0.68
            && (lastMapBottomP ?: -1f) in 0.32 .. 0.39
            && (lastMapLeftP ?: -1f) in 0.83 .. 0.95
            && (lastMapRightP ?: -1f) in 0.40 .. 0.73
            && anaPathfindingModeFM == MODE_PATHFINDING_P4
        ) {
            // [上,0s,0.6724929,c:80][下,0s,0.3735091,c:45][左,0s,0.9202279,c:3][右,0s,0.72792023,c:21]][Road,c:80]
            // [上,0s,0.49722558,c:56][下,0s,0.34383327,c:53][左,0s,0.8632479,c:14][右,0s,0.3962149,c:7]][Road,c:89]
            printLog { "analystFM 节点.P4特征位去右上角Boss B4" }
            anaPathfindingModeFM = MODE_PATHFINDING_P5
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.18 .. 0.51
            && (lastMapBottomP ?: -1f) in 0.63 .. 0.86
            && (lastMapLeftP ?: -1f) in 0.18 .. 0.76
            && (lastMapRightP ?: -1f) in 0.70 .. 0.86
            && anaPathfindingModeFM == MODE_PATHFINDING_P4
        ) {
            printLog { "analystFM 节点.P4特征位去右上角Boss B67" }
            // [上,0s,0.26961708,c:45][下,0s,0.8594633,c:20][左,0s,0.2611865,c:34][右,0s,0.8474545,c:23]][Road,c:63]
            // [上,0s,0.25863153,c:45][下,0s,0.6967771,c:44][左,0s,0.21230158,c:28][右,0s,0.79461277,c:33]][Road,c:71]
            // [上,0s,0.3691873,c:65][下,0s,0.70974576,c:40][左,0s,0.5808913,c:28][右,1s,c:0]][Road,c:73]
            // [上,0s,0.50706214,c:78][下,0s,0.64527845,c:42][左,0s,0.7888572,c:27][右,0s,0.7694166,c:23]][Road,c:84]
            // [上,0s,0.22420458,c:38][下,0s,0.7600818,c:29][左,0s,0.22911498,c:31][右,0s,0.81054133,c:30]][Road,c:69]
            anaPathfindingModeFM = MODE_PATHFINDING_P5
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.42 .. 0.54
            && (lastMapBottomP ?: -1f) in 0.55 .. 0.63
            && (lastMapLeftP ?: -1f) in 0.44 .. 0.67
            && (lastMapRightP ?: -1f) in 0.40 .. 0.53
            && anaPathfindingModeFM == MODE_PATHFINDING_P2
        ) {
            printLog { "analystFM 节点.P2起点卡点往右走一步再往下" }
            // [上,0s,0.47175142,c:91][下,0s,0.5920156,c:68][左,0s,0.5417638,c:22][右,0s,0.4335963,c:65]][Road,c:115]
            // [上,0s,0.45224646,c:84][下,0s,0.605616,c:67][左,0s,0.47388414,c:27][右,0s,0.4389942,c:69]][Road,c:115]
            // [上,0s,0.51029897,c:96][下,0s,0.58662903,c:75][左,0s,0.6350733,c:28][右,0s,0.50587606,c:80]][Road,c:114]
            anaLastSMapFMFeature5Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.38 .. 0.47
            && (lastMapLeftP == null || (lastMapLeftP ?: -1f) in 0.87 .. 0.96)
            && (lastMapRightP == null || (lastMapRightP ?: -1f) in 0.88 .. 0.97)
            && anaPathfindingModeFM == MODE_PATHFINDING_P5
        ) {
            printLog { "analystFM 节点.P5 1层Boss击破去新场景" }
            // [上,93s,c:0][下,0s,0.41450295,c:94][左,65s,c:0][右,86s,c:0]][Road,c:33]
            // [上,104s,c:0][下,0s,0.4321284,c:113][左,0s,0.9273504,c:1][右,96s,c:0]][Road,c:42]
            // [上,114s,c:0][下,0s,0.44482285,c:107][左,0s,0.9166667,c:2][右,106s,c:0]][Road,c:38]
            anaLastSMapFMFeature7Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.58 .. 0.84
            && lastMapLeftP == null
            && lastMapRightP == null
            && System.currentTimeMillis() - lastBlueDoorTs < 3000
//            && anaPathfindingModeFM == MODE_PATHFINDING_P5
        ) {
            printLog { "analystFM 节点.P6 起点.1层Boss击破抵达新场景 A" }
            // [上,1746263390s,c:0][下,0s,0.67926985,c:13][左,129s,c:0][右,120s,c:0]][Road,c:15]
            // [上,1746263402s,c:0][下,0s,0.7655367,c:15][左,141s,c:0][右,132s,c:0]][Road,c:16]
            // [上,1746263413s,c:0][下,0s,0.7754237,c:18][左,152s,c:0][右,143s,c:0]][Road,c:18]
            anaPathfindingModeFM = MODE_PATHFINDING_P6
            anaLastSMapFMFeature20Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.85 .. 0.93
            && lastMapLeftP == null
            && (lastMapRightP ?: -1f) in 0.90 .. 0.96
            && System.currentTimeMillis() - lastBlueDoorTs < 3000
            && anaPathfindingModeFM == MODE_PATHFINDING_P5
        ) {
            printLog { "analystFM 节点.P6 起点.1层Boss击破抵达新场景 B" }
            // 刚进来
            // [上,19s,c:0][下,0s,0.8922208,c:13][左,6s,c:0][右,0s,0.93002135,c:8]][Road,c:24]
            // [上,17s,c:0][下,0s,0.8922208,c:13][左,1s,c:0][右,0s,0.93002135,c:8]][Road,c:25]
            // [上,7s,c:0][下,0s,0.8922208,c:13][左,2s,c:0][右,0s,0.93002135,c:8]][Road,c:25]
            anaPathfindingModeFM = MODE_PATHFINDING_P6
            anaLastSMapFMFeature20Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && lastMapTopP == null
            && lastMapBottomP == null
            && lastMapLeftP == null
            && lastMapRightP == null
            && anaPathfindingModeFM == MODE_PATHFINDING_P6
            && System.currentTimeMillis() - anaLastSMapFMFeature8Ts > 5000
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 4000
            && !bsSceneSettle && !bsSceneSettleBlacksmith
            && System.currentTimeMillis() - anaLastSceneSettleTs > 10000
        ) {
            printLog { "analystFM 节点.P6 电梯清理敌人" }
            anaLastSMapFMFeature8Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.32 .. 0.50
            && (lastMapBottomP ?: -1f) in 0.12 .. 0.32
            && (lastMapLeftP ?: -1f) in 0.40 .. 0.58
            && lastMapRightP == null
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 3000
            && anaPathfindingModeFM == MODE_PATHFINDING_P1 // P4小boss战斗区域误判
        ) {
            printLog { "analystFM 节点.P1去顶部脱离小卡路往左 A" }
            // [上,0s,0.40516546,c:63][下,0s,0.16486904,c:22][左,0s,0.53418803,c:45][右,1746844722s,c:0]][Road,c:32]
            // [上,0s,0.46091467,c:58][下,0s,0.18573445,c:30][左,0s,0.555158,c:43][右,1746844754s,c:0]][Road,c:34]
            // 靠外面点
            // [上,0s,0.45684242,c:54][下,0s,0.3335351,c:28][左,0s,0.37179488,c:8][右,2s,c:0]][Road,c:37]
            // 最里侧往右走 可能状态不是P1
            // [上,0s,0.36720094,c:92][下,0s,0.2901826,c:69][左,0s,0.48109794,c:78][右,114s,c:0]][Road,c:73]
            // [上,0s,0.34370148,c:91][下,0s,0.29958773,c:74][左,0s,0.4859353,c:79][右,129s,c:0]][Road,c:71]
            anaLastSMapFMFeature9Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 2000
            && (lastMapTopP ?: -1f) in 0.46 .. 0.54
            && (lastMapBottomP ?: -1f) in 0.45 .. 0.53
            && lastMapLeftP == null
            && (lastMapRightP ?: -1f) in 0.90 .. 0.98
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 1000
            && anaPathfindingModeFM == MODE_PATHFINDING_P1 // P4小boss战斗区域误判
        ) {
            printLog { "analystFM 节点.P1去顶部脱离小卡路往左 B" }
            // 靠外面点
            //  [上,0s,0.50034875,c:81][下,0s,0.4913272,c:57][左,1s,c:0][右,0s,0.94159544,c:6]][Road,c:80]
            anaLastSMapFMFeature9Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 2000
            && (lastMapTopP ?: -1f) in 0.79 .. 0.86
            && (lastMapBottomP ?: -1f) in 0.26 .. 0.43
            && (lastMapLeftP ?: -1f) in 0.45 .. 0.76
            && (lastMapRightP ?: -1f) in 0.38 .. 0.45
            && anaPathfindingModeFM == MODE_PATHFINDING_P4
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 3000
        ) {
            printLog { "analystFM 节点.P4回副本起点往左走第一个小卡角" }
            // [上,0s,0.83349025,c:27][下,0s,0.40333685,c:64][左,0s,0.48611113,c:30][右,0s,0.4105938,c:38]][Road,c:34]
            // [上,0s,0.82144946,c:29][下,0s,0.2933241,c:49][左,0s,0.7300151,c:17][右,0s,0.42808005,c:41]][Road,c:33]
            anaLastSMapFMFeature10Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.36 .. 0.53
            && (lastMapLeftP ?: -1f) in 0.58 .. 0.70
            && (lastMapRightP == null || (lastMapRightP ?: -1f) in 0.67 .. 0.73)
            && anaPathfindingModeFM == MODE_PATHFINDING_P4
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 3000
        ) {
            printLog { "analystFM 节点.P4回副本起点往左走第二个卡角" }
            // [上,67s,c:0][下,0s,0.5240113,c:45][左,0s,0.6184926,c:33][右,0s,0.7083333,c:16]][Road,c:21]
            // [上,82s,c:0][下,0s,0.3968555,c:38][左,0s,0.67513734,c:28][右,6s,c:0]][Road,c:14]
            anaLastSMapFMFeature11Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.88 .. 0.97
            && (lastMapBottomP ?: -1f) in 0.24 .. 0.32
            && (lastMapLeftP ?: -1f) in 0.78 .. 0.87
            && (lastMapRightP ?: -1f) in 0.15 .. 0.25
            && anaPathfindingModeFM == MODE_PATHFINDING_P5
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 3000
        ) {
            printLog { "analystFM 节点.P5开门的上侧" }
            // [上,0s,0.9491525,c:5][下,0s,0.29788136,c:50][左,0s,0.84722227,c:6][右,0s,0.23604825,c:17]][Road,c:16]
            // [上,0s,0.9179507,c:11][下,0s,0.26497832,c:43][左,0s,0.84340656,c:7][右,0s,0.17948718,c:10]][Road,c:22]
            // [上,0s,0.9413842,c:6][下,0s,0.28047243,c:47][左,0s,0.8169516,c:9][右,0s,0.204142,c:13]][Road,c:20]
            // [上,0s,0.9555085,c:2][下,0s,0.2927966,c:50][左,0s,0.84340656,c:7][右,0s,0.22008546,c:15]][Road,c:17]
            anaLastSMapFMFeature12Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.64 .. 0.70
            && (lastMapBottomP ?: -1f) in 0.12 .. 0.18
            && (lastMapLeftP ?: -1f) in 0.65 .. 0.71
            && lastMapRightP == null
            && anaPathfindingModeFM == MODE_PATHFINDING_P5
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 3000
        ) {
            printLog { "analystFM 节点.P5开门的下侧" }
            // [上,0s,0.679202,c:24][下,0s,0.15536724,c:15][左,0s,0.6838732,c:19][右,22s,c:0]][Road,c:23]
            // [上,0s,0.679202,c:24][下,0s,0.15536724,c:15][左,0s,0.6838732,c:19][右,8s,c:0]][Road,c:23]
            anaLastSMapFMFeature13Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.76 .. 0.87
            && (lastMapBottomP ?: -1f) in 0.17 .. 0.28
            && (lastMapLeftP ?: -1f) in 0.70 .. 0.81
            && (lastMapRightP == null || (lastMapRightP ?: -1f) in 0.09 .. 0.15)
            //&& anaPathfindingModeFM == MODE_PATHFINDING_P5
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 3000
        ) {
            printLog { "analystFM 节点.P5开门门前" }
            // [上,0s,0.83192086,c:21][下,0s,0.2651836,c:24][左,0s,0.7639517,c:17][右,3s,c:0]][Road,c:23]
            // [上,0s,0.85920644,c:22][下,0s,0.24202392,c:34][左,0s,0.79339254,c:13][右,0s,0.12606837,c:3]][Road,c:23]
            // [上,0s,0.78601694,c:22][下,0s,0.19840477,c:17][左,0s,0.7223558,c:16][右,3s,c:0]][Road,c:24]
            anaLastSMapFMFeature14Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.54 .. 0.65
            && (lastMapBottomP == null || (lastMapBottomP ?: -1f) in 0.24 .. 0.34)
            && (lastMapLeftP == null || (lastMapLeftP ?: -1f) in 0.22 .. 0.32)
            && (lastMapRightP ?: -1f) in 0.15 .. 0.48
            && anaPathfindingModeFM == MODE_PATHFINDING_P4
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 3000
        ) {
            printLog { "analystFM 节点.P4走错到最下面的地方" }
            // [上,0s,0.57514125,c:75][下,3s,c:0][左,4s,c:0][右,0s,0.17236468,c:9]][Road,c:28]
            // [上,0s,0.60188186,c:68][下,38s,c:0][左,38s,c:0][右,0s,0.18822844,c:11]][Road,c:31]
            // [上,0s,0.6205997,c:65][下,0s,0.29872882,c:2][左,0s,0.27564102,c:1][右,0s,0.42699432,c:36]][Road,c:39]
            // [上,0s,0.5940927,c:68][下,1s,c:0][左,0s,0.38876322,c:17][右,0s,0.4679487,c:26]][Road,c:41]
            anaLastSMapFMFeature15Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.57 .. 0.81
            && (lastMapBottomP ?: -1f) in 0.49 .. 0.76
            && lastMapLeftP == null
            && (lastMapRightP ?: -1f) in 0.46 .. 0.57
            && anaPathfindingModeFM == MODE_PATHFINDING_P4
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 3000
        ) {
            printLog { "analystFM 节点.P4走错死胡同" }
            // [上,0s,0.6045198,c:30][下,0s,0.7306968,c:18][左,160s,c:0][右,0s,0.54467756,c:33]][Road,c:22]
            // [上,0s,0.78177965,c:20][下,0s,0.5242131,c:42][左,170s,c:0][右,0s,0.49156547,c:38]][Road,c:28]
            anaLastSMapFMFeature16Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.21 .. 0.29
            && (lastMapBottomP ?: -1f) in 0.53 .. 0.61
            && lastMapLeftP == null
            && lastMapRightP == null
            && anaPathfindingModeFM == MODE_PATHFINDING_P6
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
            && System.currentTimeMillis() - xLastAtkTs > 3000
        ) {
            printLog { "analystFM 节点.P6 电梯传送口" }
            // [上,0s,0.24463277,c:25][下,0s,0.5674827,c:36][左,44s,c:0][右,41s,c:0]][Road,c:40]
            // [上,0s,0.24883322,c:23][下,0s,0.5930542,c:34][左,121s,c:0][右,117s,c:0]][Road,c:43]
            // [上,0s,0.26553673,c:15][下,0s,0.5867166,c:43][左,130s,c:0][右,127s,c:0]][Road,c:41]
            anaLastSMapFMFeature18Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.50 .. 0.62
            && lastMapLeftP == null
            && lastMapRightP == null
            && System.currentTimeMillis() - lastBlueDoorTs < 2000
            && System.currentTimeMillis() - xLastAtkTs > 3000
        ) {
            printLog { "analystFM 节点.P6 复活电梯去boss" }
            // [上,86s,c:0][下,0s,0.5329567,c:3][左,66s,c:0][右,96s,c:0]][Road,c:25]
            // [上,87s,c:0][下,0s,0.59039545,c:5][左,67s,c:0][右,98s,c:0]][Road,c:24]
            anaLastSMapFMFeature19Ts = System.currentTimeMillis()
        }

    }


    if (System.currentTimeMillis() - anaLastPageSceneEnterTs > 8000
        && System.currentTimeMillis() - xLastUnknownTs > 8000
        && System.currentTimeMillis() - anaLastHasEnemyNameTs > 4000
        && System.currentTimeMillis() - lastEliteEnemyBossTs > 4000
        && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
        && blockBlueDoor != null
        && blockBlacksmith != null
        && !bsSceneSettle && !bsSceneSettleBlacksmith
        && simpleAssertSceneCompleted(blockBlueDoor, blockBlacksmith)) { // 特有判定
        printLog { "analyst scene completed count $anaCounterSceneSettle" }
        anaCounterSceneSettle++
        if (anaCounterSceneSettle > 0) {
            printLog { "analyst scene completed" }
            anaMarkSceneSettle()
        }
    }
    if (System.currentTimeMillis() - lastBlueDoorTs > 3000
        && System.currentTimeMillis() - lastBlacksmithTs > 3000) {
        anaCounterSceneSettle = 0
    }
}
private val cFMP1StartA1 by lazy { Block("法墓起点黑上1", selfInSmallMap.x - 60.pt, selfInSmallMap.y - 30.pt, 20.pt, 20.pt) }
private val cFMP1StartA2 by lazy { Block("法墓起点黑上2", selfInSmallMap.x - 24.pt, selfInSmallMap.y - 54.pt, 20.pt, 20.pt) }
private val cFMP1StartA3 by lazy { Block("法墓起点黑上3", selfInSmallMap.x + 20.pt, selfInSmallMap.y - 90.pt, 20.pt, 20.pt) }
private val cFMP1StartA4 by lazy { Block("法墓起点黑下4", selfInSmallMap.x + 40.pt, selfInSmallMap.y + 20.pt, 30.pt, 20.pt) }
private val cFMP1StartA5 by lazy { Block("法墓起点黑下5", selfInSmallMap.x + 80.pt, selfInSmallMap.y + 0.pt, 45.pt, 20.pt) }
private val cFMP1StartA6 by lazy { Block("法墓起点门路6", selfInSmallMap.x - 34.pt, selfInSmallMap.y + 10.pt, 22.pt, 22.pt) }
private val hitFMOutBlack by lazy { setOf(0xff0D0B0A.toInt().rgb(8),) }
private val hitFMStartRoad by lazy { setOf(0xff3D372E.toInt().rgb(12),) }

fun analysisMapFMIsStartPoint(ss: Bitmap): Boolean {
    if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
        && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
        && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
        && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
        && (lastMapTopP ?: -1f) in 0.80 .. 0.90
        && lastMapBottomP == null
        && lastMapLeftP == null
        && (lastMapRightP ?: -1f) in 0.05 .. 0.15
        && lastMapRightC in 1 .. 9 // 和神庙有微妙的差距
        && anaPathfindingModeFM == MODE_PATHFINDING_P1
        && System.currentTimeMillis() - lastEliteEnemyBossTs > 10000
        && System.currentTimeMillis() - xLastAtkTs > 3000
        && System.currentTimeMillis() - lastBlueDoorTs < 3000
        && blockBlacksmith == null
    ) {
        // 增加特征块的判断
        var hitPart = 0
        // hit [fmP1Road1] 0.9722222 hitCount 35 total 36
        // hit [fmP1Road2] 0.9444444 hitCount 34 total 36
        // hit [fmP1Road3] 0.8055556 hitCount 29 total 36
        // hit [fmP1Road4] 1.0 hitCount 48 total 48
        // hit [fmP1Road5] 1.0 hitCount 72 total 72
        // hit [fmP1Road5] 1.0 hitCount 72 total 72
        if (Analysis.hit(ss, cFMP1StartA1, hitFMOutBlack, 4.pt, 0.45f,)) hitPart++ // , "p2Road1"
        if (Analysis.hit(ss, cFMP1StartA2, hitFMOutBlack, 4.pt, 0.45f,)) hitPart++ // , "p2Road2"
        if (Analysis.hit(ss, cFMP1StartA3, hitFMOutBlack, 4.pt, 0.45f,)) hitPart++ // , "p2Road3"
        if (Analysis.hit(ss, cFMP1StartA4, hitFMOutBlack, 4.pt, 0.45f,)) hitPart++ //  "p2Road4"
        if (Analysis.hit(ss, cFMP1StartA5, hitFMOutBlack, 5.pt, 0.45f,)) hitPart++ // , "p2Road5"
        if (Analysis.hit(ss, cFMP1StartA6, hitFMStartRoad, 5.pt, 0.45f,)) hitPart++ // , "p2Road5"
        if (hitPart >= 5) {
            // 这个判断很准确 新地图也准确。 确实准确有用
            printLog { "analystFM 节点.法墓副本起点" }
            // [上,0s,0.8647391,c:34][下,1748610394s,c:0][左,1748610394s,c:0][右,0s,0.08974359,c:5]][Road,c:29]
            // [上,0s,0.8534891,c:37][下,1748526114s,c:0][左,1748526114s,c:0][右,0s,0.08974359,c:5]][Road,c:32]
            // [上,0s,0.8534891,c:37][下,1748525814s,c:0][左,1748525814s,c:0][右,0s,0.08974359,c:5]][Road,c:32]
            // [上,0s,0.8454311,c:23][下,19s,c:0][左,19s,c:0][右,0s,0.13675214,c:3]][Road,c:12]
            // [上,0s,0.8603713,c:35][下,1747400592s,c:0][左,1747400592s,c:0][右,0s,0.08974359,c:5]][Road,c:31]
            anaLastSMapFMFeature17Ts = System.currentTimeMillis()
            return true
        }
    }

    return false
}

private fun simpleAssertSceneCompleted(blueDoor: Block?, blacksmith: Block?): Boolean {
    if (blueDoor == null) return false
    if (blacksmith == null) return false
    val edge = 80.pt
    return (abs(blueDoor.x - blacksmith.x) < edge && abs(blueDoor.y - blacksmith.y) < edge)
}

private fun angleSpecialAdjust(angle: Int): Int {
//    if (System.currentTimeMillis() - anaLastHasEnemyBossNameTs > 3000
//        && System.currentTimeMillis() - lastEliteEnemyTs > 3000
//        && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
//        && System.currentTimeMillis() - lastMapRedDotTs > 3000
//        && System.currentTimeMillis() - xLastAtkTs < 600
//        && System.currentTimeMillis() - sLastFeature30Ts > 1600) {
//        printLog { "analystFM 回撤清理漏怪" }
//        sLastFeature30Ts = System.currentTimeMillis()
//        return (angle + 180) % 360
//    } // 法墓没有小怪卡点不需要回头清理.

    if (angle in 60 .. 170) {
        if (System.currentTimeMillis() - xLastAtkTs > 5000
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 5000
            && System.currentTimeMillis() - lastEliteEnemyTs > 5000
            && System.currentTimeMillis() - xLastSceneEnterTs > 30000
            && System.currentTimeMillis() - xLastPetBlacksmithTs > 20000
            && System.currentTimeMillis() - xLastUnknownTs < 20000) {
            printLog { "analystFM angleSpecialAdjust $angle to 0" }
            return 0
        }
    }
    return angle
}